
package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

//继承了通用mapper接口就会自动实现增删改查常用方法
@Component
public interface BrandMapper extends Mapper<Brand> {

    //根据分类名称查询品牌指定字段列表(涉及三张表tb_brand，tb_category,tb_brand_category)多对多关系，通过中间关系表连接
    @Select("SELECT `name`,image FROM tb_brand WHERE id in (SELECT brand_id FROM tb_category_brand WHERE category_id IN (SELECT id FROM tb_category WHERE `name`=#{categoryName}))")
    public List<Map> findListByCategoryName(@Param("categoryName") String categoryName);



}
